import {takeEvery, put} from 'redux-saga/effects'
import axios from 'axios'

function* fetchUser() {
    try {
        const res = yield axios.get('/todo')
        const action = {
            type: 'inits',
            data: res.data
        }
        console.log(res.data, action)
        yield put(action)
    } catch (e) {
        console.log('404~')
    }
}

function* saga() {
    // 捕获派发的action
    yield takeEvery('user_fetch', fetchUser)
}

export default saga;
